/// 错误的包，这种在Widget使用时，Widget找不到 样式实例
/// import 'dart:ui';

import 'package:bike_ride/common/util/hysize_fit.dart';
import 'package:bike_ride/res/style/color_styles.dart';
import 'package:flutter/material.dart';


/// 全局主题样式 统一放置的地方
class ThemeStyles {
  static final pagePaddingHorizontal = 28.rpx;

  static ThemeData defaultTheme = ThemeData(
    // appBar主题
    appBarTheme: const AppBarTheme(backgroundColor: ColorStyles.color_0E6ED9),
    // 去除水波纹效果
    splashColor: ColorStyles.color_transparent,
    // 去除长按效果
    highlightColor: ColorStyles.color_transparent,
    useMaterial3: true,
    colorScheme: ColorScheme.fromSwatch(primarySwatch: createMaterialColor(ColorStyles.color_primary))
  );


  // 自定义primarySwatch方法
  static MaterialColor createMaterialColor(Color color) {
    List strengths = <double>[.05];
    Map<int, Color> swatch = {};
    final int r = color.red, g = color.green, b = color.blue;

    for (int i = 1; i < 10; i++) {
      strengths.add(0.1 * i);
    }
    for (var strength in strengths) {
      final double ds = 0.5 - strength;
      swatch[(strength * 1000).round()] = Color.fromRGBO(
        r + ((ds < 0 ? r : (255 - r)) * ds).round(),
        g + ((ds < 0 ? g : (255 - g)) * ds).round(),
        b + ((ds < 0 ? b : (255 - b)) * ds).round(),
        1,
      );
    }
    return MaterialColor(color.value, swatch);
  }

  /// 默认矩形圆角边框
  static BoxDecoration defaultBoxDecoration = BoxDecoration(
    color: ColorStyles.color_FFFFFF,
    borderRadius: BorderRadius.circular(16.rpx),
    boxShadow: [
      BoxShadow(
        color: ColorStyles.color_C6C7CB.withOpacity(0.2),
        blurRadius: 10.rpx,
        offset: Offset(0, 5.rpx),
      ),
    ],
  );
}
